package com.cow.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cow.pojo.Land;
import com.cow.service.LandService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @author 光环and鬼泣
 * @version 2018年5月29日 下午4:47:40
 */
@Api(description="土地接口")
@Controller
public class LandController {

	@Autowired
	private LandService landService;
	
	@ApiOperation(value = "获取用户土地列表", notes = "获取用户土地列表")
	@ResponseBody
	@RequestMapping(value = "/getLandList.action", method = RequestMethod.POST)
	public JSONObject getLand(HttpServletRequest req, HttpServletResponse rep) throws Exception {
		HttpSession session = req.getSession();
		List<Land> landList = landService.getLandList((String) session.getAttribute("useriId"));
		JSONObject result = new JSONObject();
		result.put("landList", JSONArray.fromObject(landList));
		return result;

	}
}
